#pragma once

class XRole;

class XRoleMgr
{
public:
    XRoleMgr(void);
    ~XRoleMgr(void);

    BOOL Setup();
    void Clear();

    void Activate();

    XRole* AddRole(const char szRoleName[], DWORD dwRoleID);

    XRole* GetRole(DWORD dwRoleID);
    XRole* GetRole(const char szRoleName[]);

private:
    struct XNameLess
    {
        bool operator()(const char* pszX, const char* pszY) const
        {
            return STR_CASE_CMP(pszX, pszY) < 0;
        }
    };

    struct XNameStringLess
    {
        bool operator()(const std::string& strX, const std::string& strY) const
        {
            const char* pszX = strX.c_str();
            const char* pszY = strY.c_str();
            return STR_CASE_CMP(pszX, pszY) < 0;
        }
    };

    typedef std::vector<XRole*>  XRoleTable;
    XRoleTable         m_RoleTable;

    typedef std::map<const char*, XRole*, XNameLess> XRoleNameIndex;
    XRoleNameIndex    m_RoleNameIndex;
};

extern XRoleMgr* g_pRoleMgr;